package com.qkst.website.backstage.controller;

import java.io.IOException;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.qkst.website.backstage.entity.EtlServerInfo;
import com.qkst.website.backstage.service.EtlServerInfoServer;
import com.qkst.website.common.core.BaseController;

@Controller
@RequestMapping("/backstage")
public class LoginController  extends BaseController {
	
	@Resource(name="etlServerInfoServer")
	private EtlServerInfoServer etlServerInfoServer;
	
	@RequestMapping(value="/etlServerInfo.do",method={RequestMethod.POST})
	@ResponseBody
	public List<EtlServerInfo> queryAll(HttpServletRequest request){
		List<EtlServerInfo> etlServerInfoList= etlServerInfoServer.getByAll();
		return etlServerInfoList;
	}
	@RequestMapping(value="/login.do",method={RequestMethod.GET})
	public ModelAndView login(HttpServletRequest request) throws IOException{
		 ModelAndView mv=this.backstageModelAndView("login");
		 mv.addObject("username","110@qq.com");
		 mv.getModel().put("password", "123456");
		return mv;
	}
	
	/**
	 * 登陆成功进入首页
	 * @param request
	 * @param username
	 * @param password
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value="/main.do",method={RequestMethod.GET})
	public ModelAndView main(HttpServletRequest request,String username,String password) throws IOException{
		 ModelAndView mv=null;
		 if("110@qq.com".equals(username) && "123456".equals(password)){
			 mv=this.backstageModelAndView("index");
		 }else{
			 mv=this.backstageModelAndView("login");
		 }
		 mv.addObject("username",username);
		 mv.getModel().put("password", password);
		return mv;
	}
	
	
	

}
